package com.zhangtai.modules.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhangtai.modules.dto.ScoreRaterDto;
import com.zhangtai.modules.entity.score.ScoreRaterEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-10-14 15:03:55
 */
@Mapper
public interface ScoreRaterDao extends BaseMapper<ScoreRaterEntity> {

    @Select("<script>   SELECT\n" +
            "\tts.serial_number,\n" +
            "\tts.oid,\n" +
            "\tts.name,\n" +
            "\tts.org_id,\n" +
            "\tts.unit_id,\n" +
            "\tts.job_id,\n" +
            "\tts.program_id,\n" +
            "\ttsp.program_name," +
            "\ttsr.status,\n" +
            "\ttsr.create_time,\n" +
            "\ttsr.id,\n" +
            "\ttsr.score_id,\n" +
            "\ttsr.type,\n" +
            "\ttsr.rater_score,\n" +
            "\ttsr.score_time " +
            "  FROM\n" +
            "\ttb_score_rater tsr\n" +
            "\tLEFT JOIN tb_score ts ON ts.id = tsr.score_id\n" +
            "\tLEFT JOIN tb_score_program tsp ON ts.program_id = tsp.id " +
            " <where> tsr.is_delete = 0 and ( ts.status= 1 or ts.status= 2 )\n" +
            "\tAND \ttsr.oid  = #{oid} \n" +
            "<if test='status!=null'> and tsr.status = #{status} </if>" +
            "<if test='status==null'> and (tsr.status =1 or tsr.status =2 ) </if>" +
            "</where> ORDER BY tsr.create_time DESC" +
            "</script>")
    public List<ScoreRaterDto> getScoreScorePage(@Param(value = "oid") Long oid, @Param(value = "status") Integer status, Page<ScoreRaterDto> page);

}
